﻿using FarmSmartSleep.Common.Domain.BeginTable;
using FarmSmartSleep.Common.Dtos;
using FarmSmartSleep.Common.Infrastructure;
using MediatR;

namespace FarmSmartSleep.Organ.API.Application.SleepInfoCommands.RecordCommands
{
    public class MaleCodeHandler : IRequestHandler<MaleCodeCommand, Result>
    {
        private readonly IBaseRepository<SleepInfor> sleepinforbaseRepository;

        public MaleCodeHandler(IBaseRepository<SleepInfor> sleepinforbaseRepository)
        {
            this.sleepinforbaseRepository = sleepinforbaseRepository;
        }

        public async Task<Result> Handle(MaleCodeCommand request, CancellationToken cancellationToken)
        {
            var result= new Result() { Code=(int)CodeEnum.search};
            var list=sleepinforbaseRepository.GetAll().Where(x=>x.SleepInforId==request.mid).FirstOrDefault();
            result.Data = list;
            return result;
        }
    }
}
